package com.example.controller;

import com.example.pojo.Feedback;
import com.example.pojo.Result;
import com.example.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;

    @RequestMapping(value = "/add")
    public Result add(@RequestBody Feedback feedback) {
        feedbackService.add(feedback);
        return Result.success();
    }

    @RequestMapping(value = "/list")
    public Result list() {
        List<Feedback> list = feedbackService.list();
        return Result.success(list);
    }

    @RequestMapping(value = "/delete")
    public Result delete(Integer id) {
        feedbackService.delete(id);
        return Result.success();
    }

    @RequestMapping(value = "/detail")
    public Result detail(Integer id) {
        Feedback feedback = feedbackService.detail(id);
        return Result.success(feedback);
    }

    @RequestMapping(value = "/update")
    public Result update(@RequestBody Feedback feedback) {
        feedbackService.update(feedback);
        return Result.success();
    }
}
